home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 47.7z / BS1 part 47 / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].7z / ImageMaster RT v1.50b (1994)(Black Belt Systems)(Disk 6 of 7)[HD].adf / piarc.lzh.parta / clipwr.rexx < prev    next >
OS/2 REXX Batch file  |  1994-03-17  |  4KB  |  154 lines

  1. /*
  2.  * CLIPWR.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: April 18, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.02
  9.  */
  10. parse arg '"' filename '"' buffer
  11. call pragma('stack',20000);
  12.  
  13. /*
  14.  * open rexxsupport.library -- needed for some functions
  15.  */
  16. if ~show('L',"rexxsupport.library") then do
  17.   if addlib('rexxsupport.library',0,-30,0) then do
  18.       /* everything's ok */
  19.     end;
  20.   else do
  21.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  22.     say 'Cannot operate CLIPWR.rexx without this library - sorry!';
  23.     exit 10;
  24.     end;
  25.   end;
  26.  
  27. /*
  28.  * This will automatically direct the script to the proper
  29.  * software, if it is running.
  30.  */
  31. prtnme = 'IP_Port'; /* assume Image Professional */
  32. if show('P','IP_Port') = 0 then do
  33.   if show('P','IM_Port') = 0 then do
  34.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  35.     say "This script requires IP, IM or IM F/c to run!";
  36.     exit(20);
  37.     end;
  38.   else do
  39.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  40.     end;                 /* We make em, user's break em.          */
  41.   end;
  42.  
  43.   /*
  44.    * This code attempts to read a file called "picmdpath" from REXX:
  45.    * If it can't find it, the script will assume that the commands
  46.    * associated with this PI Module are in "c:". If the file exists,
  47.    * the script will look in the path that is specified in the file.
  48.    * If you create this file, you MUST put a complete, correct path
  49.    * in it; if the commands are in a sub-directory, you have to put
  50.    * the trailing slash on the path (like, device:dir/).
  51.    * 
  52.    */
  53.   cmdpath = 'c:';
  54.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  55.     do
  56.       cmdpath = readln(fhandle);
  57.       call close(fhandle);  /* close the file    */
  58.     end
  59.  
  60. options;
  61. address;
  62.  
  63.   address(prtnme);
  64.   options results;
  65.   'current';
  66.   bufdata = result; /* get name of buffer, if there is one */
  67.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  68.   if bname ~= '<none>' then do
  69.     bufname = bname;
  70.     end;
  71.  
  72.   address(prtnme);
  73.  
  74. 'tofront';
  75.  
  76.   options results;
  77.   'asknumber '||'"Which clipboard unit?" 0'
  78.   unit = result;
  79.   
  80.   if buffer = 0 then do
  81.     'jackin';
  82.     jackadr = result;
  83.     options;
  84.     end;
  85.   else do
  86.     'backin '||buffer;
  87.     jackadr = result;
  88.     options;
  89.     end;
  90.  
  91.   'wbtofront';
  92.   'lockimage '||bnum;
  93.   address command cmdpath||'CLIPWR '||jackadr||' '||unit;
  94.   'unlockimage '||bnum;
  95.  
  96.   address(prtnme);
  97.   'imtofront';
  98.   'finish';
  99.   address;
  100.  
  101.   exit 0;
  102.  
  103. /*
  104.  * gimmepath
  105.  *
  106.  * This takes the provided argument and sucks the path out of it, then
  107.  * returns that path to the caller, sans file name.
  108.  */
  109. gimmepath:
  110.   arg fullnamegx;
  111.     tempgx = reverse(fullnamegx);
  112.     lengx = length(fullnamegx);   /* get length of string */
  113.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  114.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  115.     seploc = 0; /* assumes current dir, no path supplied */
  116.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  117.       seploc = (lengx - slashdex)+1;
  118.       end;
  119.     else do
  120.       if colondex ~= 0 then do /* we assume we are on a device */
  121.         seploc = (lengx - colondex)+1;
  122.         end;
  123.       end;
  124.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  125.   gxpath = left(fullnamegx,seploc);
  126.   return(gxpath);
  127.  
  128. /*
  129.  * Since this script can't be expected to know where the CD of the user
  130.  * is when this cmd is invoked, we have to check the path the user
  131.  * provides - if it's not specified right from a root, then we have
  132.  * to make it a complete specification from the root.
  133.  */
  134. expandfilename:
  135.   parse arg jfile;
  136.   if index(jfile,':') = 0 then do
  137.     curdir = pragma(D);
  138.     if right(curdir,1) ~= ':' then do
  139.       if right(curdir,1) ~= '/' then do
  140.         if curdir ~= '' then do
  141.           curdir = curdir || '/';
  142.           end;
  143.         end;
  144.       end;
  145.     jfile = curdir||jfile;
  146.     end;
  147.   return(jfile);
  148.  
  149. rvalue:
  150.   wordnum = c2d(readch(fhandle,1)) * 256;
  151.   wordnum = wordnum + c2d(readch(fhandle,1));
  152.   return wordnum;
  153.  
  154.